package com.epam.my.Pages;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import com.epam.my.Kulibaba.Email;

public class RightMailPage extends InternalPage {
	@FindBy(id = "subject")
	public WebElement subject;
	@FindBy(css = "input.uiAutocompleteTextInput")
	public WebElement sendTo;
	@FindBy(xpath = "//button[@class = 'uiButton uiButtonNormal appComposeSend']")
	public WebElement sendButton;
	

	public boolean isOnThisPage() {
		return sendTo.isDisplayed() && subject.isDisplayed();
	}

	public MailPage sendNewEmail(Email email) {
		sendTo.clear();
		sendTo.sendKeys(email.senderAddress);
		subject.clear();
		subject.sendKeys(email.emailSubject);
		sendButton.click();
		 return MyPageFactory.getPage(driver, MailPage.class);
	}	
	

	@Override
	public void tryToOpen() {
		MyPageFactory.getPage(driver, MailPage.class).createNewEmail();
	}

}
